/**
 * @Author: 小狐
 * @Date: 2021/11/30 13:42
 * @Describe 主动去学习
 *
 */
package resp_gin

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type result struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func Success(c *gin.Context, data interface{}) {
	response := &result{
		Code:    SUCCESS,
		Message: "成功",
		Data:    data,
	}
	c.JSON(http.StatusOK, response)
}
func Error(c *gin.Context, message string) {
	response := &result{
		Code:    ERROR,
		Message: message,
	}
	c.JSON(http.StatusOK, response)
}

//func (r *Result) Error(c *gin.Context,message string)  {
//	response := &Result{
//		code: ERROR,
//		message:message,
//	}
//	c.JSON(http.StatusOK,response)
//}
